package vn.kiemviec.app.data;

import java.util.ArrayList;
import java.util.Date;

import org.json.JSONArray;
import org.json.JSONObject;

import vn.kiemviec.app.utils.LogTools;

/**
 * Truong Tan Trung
 *
 */

//JOB_ID	ID Job
//JOB_TITLE	Tên Job
//JOB_SUBCONTENT	Nội dung ngắn
//JOB_ACTIVEDATE1	Ngày kích hoạt job
//JOB_COMPETITION	
//EMP_NAME	Tên nhà tuyển dụng
//JOB_CODE	Mã công việc
//JOB_LASTDATE	Hạn chót nhận hồ sơ
//JOB_CONTACT_HIDE	Chuỗi bit bảo mật job
//EMP_ID	ID nhà tuyển dụng

//LOCATION_NAME	Chuỗi tỉnh thành 
//JOB_SALARYUNIT	Đơn vị lương
//JOB_FROMSALARY	Lương từ
//JOB_TOSALARY	Lương đến
//JOB_ISBOLD	Job có order in đậm đỏ?
//RECNO	Vị trí record đang xem
//TOTAL_ROWS	Tổng số record lấy ra
//JOB_ACTIVEDATE	Ngày kích hoạt job

public class JobEntry  {

	public String JobID;
	public String Title;
	public String Company;	
	
	public String LastDate;
	public String Location;	
	
	public String DeadLine;	
	public String Industry;
	public String Degree;
	public String WorkingType;
	public String Level;
	public String Salary;
	public String Age;
	public String Gender;
	
	public String Description;
	
	public String ContactEmail;
	public String ContactName;
	public String ContactCompany;
	public String ContactAddress;
	public String CountryName;
	//Contact info
	
	public JobEntry(){
		
	}
	
	public static ArrayList<JobEntry> getList(){
		
		ArrayList<JobEntry> list = new ArrayList<JobEntry>();
		for(int i=0;i<30;i++){
			JobEntry entry = new JobEntry();
			list.add(entry);
		}
		return list;
	}
	
	public static ArrayList<JobEntry> getList(String json){
		
		ArrayList<JobEntry> list = new ArrayList<JobEntry>();
		try {
			JSONArray jrr = new JSONArray(json);
			for(int i = 0;i<jrr.length();i++){
				JSONObject jb = jrr.getJSONObject(i);
				JobEntry entry = new JobEntry();
				
				entry.JobID	= jb.getString("JOB_ID");
				entry.Title	= jb.getString("JOB_TITLE");
				entry.Company= jb.getString("EMP_NAME");
				//30-APR-13"
//				entry.LastDate	=
				entry.Location		= jb.getString("LOCATION_NAME");
				list.add(entry);
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
		for(int i=0;i<30;i++){
			JobEntry entry = new JobEntry();
			list.add(entry);
		}
		return list;
	}


	public static JobEntry getEntry(JSONObject jb) {
		// TODO Auto-generated method stub
		JobEntry entry = new JobEntry();
		try {
			entry.JobID		= jb.getString("JOB_ID");
			entry.Title		= jb.getString("JOB_TITLE");
			entry.Company	= jb.getString("EMP_NAME");
			//30-APR-13"
			entry.LastDate	= jb.getString("");
			entry.Location	= jb.getString("LOCATION_NAME");
		} catch (Exception e) {
			// TODO: handle exception
		}
		
		return entry;
	}
	
	public static JobEntry getDetailsEntry(JSONObject jb) {
		// TODO Auto-generated method stub
		JobEntry entry = new JobEntry();
		try {
			entry.JobID		= jb.getString("JOB_ID");
			entry.Title		= jb.getString("JOB_TITLE");
//			entry.Company	= jb.getString("EMP_NAME");
			//30-APR-13"
//			entry.LastDate	=
			entry.Location		= jb.getString("LOCATION_NAME");
//			entry.Industry		= jb.getString("");
			entry.WorkingType	= jb.getString("JOB_WORKING_TYPE");
//			entry.Level			= jb.getString("");
//			entry.Degree		= jb.getString("");
//			entry.Age			= jb.getString("");
//			entry.Gender		= jb.getString("JOB_GENDER");
//			entry.Salary		= jb.getString("");
//			entry.DeadLine		= jb.get("");
			entry.Description	= jb.getString("JOB_CONTENT");
			entry.ContactName	= jb.getString("JOB_CONTACT_NAME");
			entry.ContactAddress= jb.getString("JOB_CONTACT_ADDRESS");
//			entry.ContactCompany= jb.getString("");
//			entry.CountryName	= jb.getString("");
		} catch (Exception e) {
			// TODO: handle exception
			LogTools.error("parse job details error.");
		}
		
		return entry;
	}
	
//	public static void 
}
